'use strict';

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

var vue = new Vue({
    data: {
        userid: '',
        username: '',
        groupid: 0,
        power: [],
        menu: []
    },
    methods: {
        logout: function logout() {
            this.$confirm('确定要安全退出吗？', '系统提醒', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(function () {
                Cookies.remove('userid');
                Cookies.remove('username');
                Cookies.remove('groupid');
                Cookies.remove('auth');
                Cookies.remove('power');
                location.replace('/admin/welcome/login');
            }).catch(function () {});
        }
    },
    created: function created() {},
    mounted: function () {
        var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
            var auth, userid, username, groupid, power, response, data;
            return regeneratorRuntime.wrap(function _callee$(_context) {
                while (1) {
                    switch (_context.prev = _context.next) {
                        case 0:
                            this.$check_login();

                            $('#target,#mymenu').height($(window).height() - $('#target').offset().top - 20);

                            auth = Cookies.get('auth');
                            userid = Cookies.get('userid');
                            username = Cookies.get('username');
                            groupid = Cookies.get('groupid');
                            power = Cookies.get('power');


                            this.userid = userid;
                            this.username = username;
                            this.groupid = groupid;
                            this.power = JSON.parse(power);

                            _context.prev = 11;
                            _context.next = 14;
                            return axios.post('/api/menu/left', {});

                        case 14:
                            response = _context.sent;
                            data = response.data;

                            this.menu = data.data;
                            _context.next = 22;
                            break;

                        case 19:
                            _context.prev = 19;
                            _context.t0 = _context['catch'](11);

                            this.$message.error(_context.t0.toString());

                        case 22:
                        case 'end':
                            return _context.stop();
                    }
                }
            }, _callee, this, [[11, 19]]);
        }));

        function mounted() {
            return _ref.apply(this, arguments);
        }

        return mounted;
    }()
}).$mount('#app');